package com.mc2.docapp.disabilityassessmenttool.UpperLimb;

import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import lombok.Data;

@Data
public class C_loss_in_10_co_ordinated_activities extends RealmObject {
    @PrimaryKey
    public int id;
    private CustDataType overheadLifting= new CustDataType();
    private CustDataType touchingNose= new CustDataType();
    private CustDataType eating= new CustDataType();
    private CustDataType combing= new CustDataType();
    private CustDataType puttingShirt= new CustDataType();
    private CustDataType ablution= new CustDataType();
    private CustDataType drinkingFromGlass= new CustDataType();
    private CustDataType buttoning= new CustDataType();
    private CustDataType tyingKnot= new CustDataType();
    private CustDataType writing= new CustDataType();
    private InnerCalculations inner_calculations = new InnerCalculations() ;

    public C_loss_in_10_co_ordinated_activities() {
    }

    public C_loss_in_10_co_ordinated_activities(int id, CustDataType overheadLifting, CustDataType touchingNose, CustDataType eating, CustDataType combing, CustDataType puttingShirt, CustDataType ablution, CustDataType drinkingFromGlass, CustDataType buttoning, CustDataType tyingKnot, CustDataType writing, InnerCalculations inner_calculations) {
        this.id = id;
        this.overheadLifting = overheadLifting;
        this.touchingNose = touchingNose;
        this.eating = eating;
        this.combing = combing;
        this.puttingShirt = puttingShirt;
        this.ablution = ablution;
        this.drinkingFromGlass = drinkingFromGlass;
        this.buttoning = buttoning;
        this.tyingKnot = tyingKnot;
        this.writing = writing;
        this.inner_calculations = inner_calculations;
    }

    public C_loss_in_10_co_ordinated_activities strip(C_loss_in_10_co_ordinated_activities dt) {
        return new C_loss_in_10_co_ordinated_activities(dt.getId(), dt.getOverheadLifting(), dt.getTouchingNose(), dt.getEating(),
                dt.getCombing(), dt.getPuttingShirt(), dt.getAblution(), dt.getDrinkingFromGlass(), dt.getButtoning(), dt.getTyingKnot(),
                dt.getWriting(), dt.getInner_calculations());

    }

    public void calc(C_loss_in_10_co_ordinated_activities c_loss_in_10_co_ordinated_activities) {

        double pa = c_loss_in_10_co_ordinated_activities.getOverheadLifting().getActual_left();
        c_loss_in_10_co_ordinated_activities.getOverheadLifting().setPerc_loss_left(pa);

        double pb = c_loss_in_10_co_ordinated_activities.getTouchingNose().getActual_left();
        c_loss_in_10_co_ordinated_activities.getTouchingNose().setPerc_loss_left(pb);

        double pc = c_loss_in_10_co_ordinated_activities.getEating().getActual_left();
        c_loss_in_10_co_ordinated_activities.getEating().setPerc_loss_left(pc);

        double pd = c_loss_in_10_co_ordinated_activities.getCombing().getActual_left();
        c_loss_in_10_co_ordinated_activities.getCombing().setPerc_loss_left(pd);

        double pe = c_loss_in_10_co_ordinated_activities.getPuttingShirt().getActual_left();
        c_loss_in_10_co_ordinated_activities.getPuttingShirt().setPerc_loss_left(pe);

        double pf = c_loss_in_10_co_ordinated_activities.getAblution().getActual_left();
        c_loss_in_10_co_ordinated_activities.getAblution().setPerc_loss_left(pf);

        double pg = c_loss_in_10_co_ordinated_activities.getDrinkingFromGlass().getActual_left();
        c_loss_in_10_co_ordinated_activities.getDrinkingFromGlass().setPerc_loss_left(pg);

        double ph = c_loss_in_10_co_ordinated_activities.getButtoning().getActual_left();
        c_loss_in_10_co_ordinated_activities.getButtoning().setPerc_loss_left(ph);

        double pi = c_loss_in_10_co_ordinated_activities.getTyingKnot().getActual_left();
        c_loss_in_10_co_ordinated_activities.getTyingKnot().setPerc_loss_left(pi);

        double pj = c_loss_in_10_co_ordinated_activities.getWriting().getActual_left();
        c_loss_in_10_co_ordinated_activities.getWriting().setPerc_loss_left(pj);

        double sumLeft = pa + pb + pc + pd + pe + pf + pg + ph + pi + pj;

        //RIGHT CAL

        pa = c_loss_in_10_co_ordinated_activities.getOverheadLifting().getActual_right();
        c_loss_in_10_co_ordinated_activities.getOverheadLifting().setPerc_loss_right(pa);

        pb = c_loss_in_10_co_ordinated_activities.getTouchingNose().getActual_right();
        c_loss_in_10_co_ordinated_activities.getTouchingNose().setPerc_loss_right(pb);

        pc = c_loss_in_10_co_ordinated_activities.getEating().getActual_right();
        c_loss_in_10_co_ordinated_activities.getEating().setPerc_loss_right(pc);

        pd = c_loss_in_10_co_ordinated_activities.getCombing().getActual_right();
        c_loss_in_10_co_ordinated_activities.getCombing().setPerc_loss_right(pd);

        pe = c_loss_in_10_co_ordinated_activities.getPuttingShirt().getActual_right();
        c_loss_in_10_co_ordinated_activities.getPuttingShirt().setPerc_loss_right(pe);

        pf = c_loss_in_10_co_ordinated_activities.getAblution().getActual_right();
        c_loss_in_10_co_ordinated_activities.getAblution().setPerc_loss_right(pf);

        pg = c_loss_in_10_co_ordinated_activities.getDrinkingFromGlass().getActual_right();
        c_loss_in_10_co_ordinated_activities.getDrinkingFromGlass().setPerc_loss_right(pg);

        ph = c_loss_in_10_co_ordinated_activities.getButtoning().getActual_right();
        c_loss_in_10_co_ordinated_activities.getButtoning().setPerc_loss_right(ph);

        pi = c_loss_in_10_co_ordinated_activities.getTyingKnot().getActual_right();
        c_loss_in_10_co_ordinated_activities.getTyingKnot().setPerc_loss_right(pi);

        pj = c_loss_in_10_co_ordinated_activities.getWriting().getActual_right();
        c_loss_in_10_co_ordinated_activities.getWriting().setPerc_loss_right(pj);

        double sumRight = pa + pb + pc + pd + pe + pf + pg + ph + pi + pj;

        c_loss_in_10_co_ordinated_activities.setInner_calculations(new InnerCalculations(
                0,
                0,
                sumRight,
                sumLeft

        ));


    }

    private double perc(double a, double normal) {
        return ((normal - a) * 100d) / (normal + 0d);
    }

}
